import {
	addConfig,
	captureRecord,
	changeConfig,
	configInfoList,
	dataAlarm,
	dataDisplay,
	nowConfigInfo, photoView, removeConfig, startConfig
} from "@/api/display";

export function showMessage(self,message,type){
	self.$message({
		showClose: true,
		message: message,
		type: type
	});
}
// 获取当前配置信息
export function getNowConfigInfo() {
	return new Promise((resolve, reject) => {
		nowConfigInfo().then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 获取配置列表
export function getConfigInfoList(uid){
	return new Promise((resolve, reject) => {
		configInfoList(uid).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 发送修改配置
export function sendChangeConfig(option) {
	return new Promise((resolve, reject) => {
		changeConfig(option).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 发送开启配置
export function sendStartConfig(sid) {
	return new Promise((resolve, reject) => {
		startConfig(sid).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 发送删除配置
export function sendRemoveConfig(sid) {
	return new Promise((resolve, reject) => {
		removeConfig(sid).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 获取抓怕记录
export function getCaptureRecord(option) {
	return new Promise((resolve, reject) => {
		captureRecord(option).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) =>{
			reject(error)
		})
	})
}
// 获取展示数据
export function getDataDisplay(uid) {
	return new Promise((resolve, reject) => {
		dataDisplay(uid).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) => {
			reject(error)
		})
	})
}

// 获取警报数据
export function getDataAlarm(uid) {
	return new Promise((resolve, reject) => {
		dataAlarm(uid).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) => {
			reject(error)
		})
	})
}

// 获取抓拍
export function getPhotoView(uid,startTime,endTime){
	return new Promise((resolve, reject) => {
		photoView(uid,startTime,endTime).then((response) => {
			let data = response.data
			resolve(data)
		}).catch((error) => {
			reject(error)
		})
	})
}
